parseln()
{
- name=`echo "$1" | cut -c0-17`
- name=${name%% *}
- rest=`echo "$1" | cut -c18- `
- read id mem cpu vcpu state tm < <(echo "$rest")
+ if [[ "$1" =~ "\(domain" ]]; then
+ name=;id=
+ else if [[ "$1" =~ "\(name" ]]; then
+ name=$(echo $1 | sed -e 's/^.*(name \(.*\))$/\1/')
+ else if [[ "$1" =~ "\(domid" ]]; then
+ id=$(echo $1 | sed -e 's/^.*(domid \(.*\))$/\1/')
+ fi; fi; fi
+
+ [ -n "$name" -a -n "$id" ] && return 0 || return 1
}
is_running()
{
rdname $1
RC=1
+ name=;id=
while read LN; do
- parseln "$LN"
+ parseln "$LN" || continue
if test $id = 0; then continue; fi
case $name in
($NM)
RC=0
;;
esac
- done < <(xm list | grep -v '^Name')
+ done < <(xm list -l | grep '(\(domain\|domid\|name\)')
return $RC
}
all_zombies()
{
+ name=;id=
while read LN; do
- parseln "$LN"
+ parseln "$LN" || continue
if test $id = 0; then continue; fi
if test "$state" != "-b---d" -a "$state" != "-----d"; then
return 1;
fi
- done < <(xm list | grep -v '^Name')
+ done < <(xm list -l | grep '(\(domain\|domid\|name\)')
return 0
}
rdnames
fi
echo -n "Shutting down Xen domains:"
+ name=;id=
while read LN; do
- parseln "$LN"
+ parseln "$LN" || continue
if test $id = 0; then continue; fi
echo -n " $name"
if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
fi
kill $WDOG_PID >/dev/null 2>&1
fi
- done < <(xm list | grep -v '^Name')
+ done < <(xm list -l | grep '(\(domain\|domid\|name\)')
# NB. this shuts down ALL Xen domains (politely), not just the ones in
# AUTODIR/*
check_domain_up()
{
+ name=;id=
while read LN; do
- parseln "$LN"
+ parseln "$LN" || continue
if test $id = 0; then continue; fi
case $name in
($1)
return 0
;;
esac
- done < <(xm list | grep -v "^Name")
+ done < <(xm list -l | grep '(\(domain\|domid\|name\)')
return 1
}